<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - 空白页</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
 <link rel="shortcut icon" href="favicon.ico">  <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
    <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
         <link rel="stylesheet" href="__STATIC__/layout/css/channel.css" type="text/css">
    <style>
		 .laydate_box, .laydate_box * {

        box-sizing:content-box;

    }
    
    </style>
</head>

<body style="color:#333;padding:3px;" class="x_sorll">
    <!-- 标题 -->
    <div class="page-heade">
      <h2 class="title_color text-center">AP费用核销支付凭证</h2>
    </div>
    <!-- 标题 -->
    <div class="contact-box">
        <button class="btn btn-info" type="button" onclick="daochuhexiao({$hid})">导出Excel</button>
    </div>
     <table class="table table-bordered text-center bud_hei" style="margin-bottom: 0">
        <tr>
            <td style="min-width: 120px;width: 120px">申请人</td>
            <td class="text-left"><a href="javascript:;">{$apply.cname}</a></td>
            <td style="min-width: 120px;width: 120px">申请人所在部门/职位</td>
            <td class="text-left">{$apply.de_name}/{$apply.job_name}</td>
            <td style="min-width: 120px;width: 120px">编号</td>
            <td class="text-left">{$apply.no}</td>
            <td style="min-width: 120px;width: 120px">提交时间</td>
            <td class="text-left">{$apply.created_on}</td>
        </tr>
        <tr>
            <td style="min-width: 120px;width: 120px">供应商名称</td>
            <td class="text-left" colspan="7">{$gys_str}</td>
        </tr>
        <table class="table-bordered table">
             <tr>
            <td><span class="colorRed font-bold">温馨提示：请在发票粘贴联上注明此申请单编号：{$apply.no}</span><a href="javascript:;">点击查看图例</a></td>
        </tr>
        </table>
    </table>
     <form id="f1">
      <table class="table table-striped table-bordered text-center bud_hei">
        <tr class="info">
            <td rowspan="2">序号</td>
            <td rowspan="2">明细编号</td>
            <td rowspan="2">原申请人</td>
            <td rowspan="2">原申请文件</td>
            <td rowspan="2">原明细编号</td>
            <td rowspan="2">渠道类型</td>
            <td rowspan="2">供应商名称</td>
            <td rowspan="2">品牌</td>
            <td rowspan="2">三级费用科目</td>
            <td colspan="3">实际投入</td>
            <td colspan="8">本次申请核销</td>
            <td rowspan="2">活动开始日期</td>
            <td rowspan="2">支付方式</td>
            <td rowspan="2">本次支付方式</td>
            <td rowspan="2">备注</td>
            <td rowspan="2">操作记录</td>
            
        </tr>
         <tr class="info">
            <td>实际投入金额</td>
            <td>已核销金额</td>
            <td>未核销金额</td>
            <td>未税核销金额</td>
            <td>有无发票</td>
            <td>发票号</td>
            <td>是否增值税(可抵扣)</td>
            <td>税率</td>
            <td>税金</td>
            <td>含税核销金额</td>
            <td>实际核销金额</td>
        </tr>
        {volist name="applyde" id="vo"}
            <tr>
                <td>{$i}</td>
                <td>{$vo.he_no}_{$vo.he_detail_no}</td>
                <td class="text-left">{$vo.cname}</td>
                <td><a href="{:url('Apapply/apply_de')}?aid={$vo.apid}">{$vo.no}</a></td>
                 <td>{$vo.no}_{$vo.detail_no}</td>
                 <td>{$vo.channel}</td>
                 <td>{$vo.gys_name}</td><td>{$vo.brand}</td><td>{$vo.kemu3}</td>
                 <td class="num2">{$vo.hanshui}</td> <td class="num2">{$vo.hexiao}</td><td class="num2">{$vo.weihe}</td>
                 <td class="num2">{$vo.hexiao_weishui}</td><td>{if condition="$vo.has_fp eq 0"}无{else/}有{/if}</td>
                 <td>{$vo.fp_no}</td><td>{if condition="$vo.dikou eq 0"}否{else/}是{/if}</td>
                 <td><span class="num2">{$vo.hexiao_shuilv}</span>%</td><td class="num2">{$vo.shuijin}</td><td class="num2">{$vo.he_hanshui}</td>
                 <td class="num2">{$vo.he_hanshui}</td> <td>{$vo.start_time}</td><td>{$vo.zffs}</td>
                 <td>
                 <input type="hidden" name="did[]" value="{$vo.ahdid}"/>
                    <select name="paymethod[]" class="form-control">
                        {volist name="pay" id="p"}
                            {if $vo.zfid==$p.id}
                            <option value='{$p.id}' selected>{$p.title}</option>
                            {else/}
                                 <option value='{$p.id}'>{$p.title}</option>
                            {/if}
                        {/volist}
                    </select>
                 </td>
                 <td>{$vo.beizhu}</td><td></td>
            </tr>
        {/volist}
        
        <tr class="trTotal1 font-bold text-right">
            <td colspan="9" class="text-right font-bold">合计</td>
            <td class="num2">{$all.hanshui}</td>
            <td class="num2">{$all.hexiao}</td>
            <td class="num2">{$all.weihe}</td>
            <td class="num2">{$all.hexiao_weishui}</td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td class="num2">{$all.shuijin}</td>
            <td class="num2">{$all.he_hanshui}</td>
            <td class="num2">{$all.he_hanshui}</td>
            <td colspan="5"></td>
        </tr>
        <tr>
        <td colspan="2">备注</td>
        <td colspan="25">{$apply.remark}</td>
        </tr>
        </table>
       
      <table class="table table-bordered text-left bud_hei">
            <tr class="info">
                <th class="text-left font-bold">审批意见</th>
            </tr>
          <tr>
              <td>华东大区-华东大区经理 <a href="javascript:;">曾小倩</a>审批动作：抄送；审批意见：OK(审批时间：2017-02-20 11:50:23)</td>
          </tr>
            <tr>
              <td>华东大区-华东大区经理 <a href="javascript:;">曾小倩</a>审批动作：抄送；审批意见：无(审批时间：2017-02-20 11:50:34)</td>
          </tr>
      </table>
     <input type="hidden" name="hid" value="{$hid}"/>
      <table class="table table-bordered text-left bud_hei">
            <tr>
                <th class="text-left info">支付信息</th>
            </tr>
            <tr>
                <td>总含税金额：<span class="num2">{$all.he_hanshui}</span>元 已支付金额：<span class="num2">{$all.zhifu_jine}</span>元 未支付金额：<span class="num2">{$all.weifu}</span>元</td>
            </tr>
            <td>
            	<table border="0" cellspacing="4">
					<tr>
						<td>
							<label for="" class="form-label">支付凭证<span class="colorRed">*</span>:</label>
						</td>
						<td>
							<input type="text" class="form-control" name="zfpz">
						</td>
						<td>
							<label for="" class="form-label">支付人<span class="colorRed">*</span>:</label>
						</td>
						<td style="width:400px">
							<div class="container-fluid">
		                        <div class="row">
		                            <div class="col-xs-8">
		                                <div class="input-group" style="display: none;" >
		                                    <input type="text" placeholder="请输入关键字或空格查询" class="cname form-control"  name="c_users_id" value="{$cuser.id}">
		                                    <div class="input-group-btn">
		                                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
		                                            <span class="caret"></span>
		                                        </button>
		                                        <ul class="dropdown-menu dropdown-menu-right" role="menu">
		                                        </ul>
		                                    </div>
		                                </div>
		                                <div class="selectedOnlyOne "  >
		                                	
		                                    <span class="inin">{$cuser.title}</span>
		                                    <span class="close">×</span>
		                                </div>
		                            </div>
		                            <div class="col-xs-4">
		                                <button type="button" class="btn btn-primary select_cname" >选择</button>
		                            </div>
		                        </div>
		                    </div>
						</td>
							<td >
								<label for="" class="form-label">支付日期<span class="colorRed">*</span>:</label>
							</td>
							<td>
								  <input type="text" id="start" class="form-control" name="zhifu_day">
							</td>
							<td>
								<label for="" class="form-label">本次支付金额(元)<span class="colorRed">*</span>:</label>
							</td>
							<td>
								<input type="text"  name="zfjin" class="form-control" >
							</td>
					</tr>
					<tr>
						<td colspan="1">
							<label for="" class="form-label">支付备注：</label>
							</td>
							<td colspan="7">
							<input type="text" name="remark" class="form-control" style="min-width: 580px;width:580px">
						</td>
					</tr>
            	</table>
			
			
			
            </td>
        </table>
        <div class="row text-center no-padding">
            <button class="btn btn-primary" type="button" id="bc">保存支付凭证</button>
            <button class="btn btn-info" type="button" onclick="back()">返回</button>
      </div>
      </form>
      {if condition="$apply.is_shengxiao eq 1"}
      <div class="SuccessImg font-bold">
        已&nbsp;生&nbsp;效
      </div>
      {/if}

 
     
      <br/>  <br/>  <br/>
 <div class="footer fixed_full text-center" id="fixBG">
         本次核销未税金额合计：<strong class="colorRed"><span class="num2">{$all.hexiao_weishui}</span>元</strong>;税金合计：<strong class="colorRed"><span class="num2">{$all.shuijin}</span>元</strong>;含税金额合计：<strong class="colorRed"><span class="num2">{$all.he_hanshui}</span>元</strong>;实际金额合计：<strong class="colorRed"><span class="num2">{$all.he_hanshui}</span>元</strong>;
    </div>
  </form>
    <!-- 全局js -->
     <!-- 全局js -->
     <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
     <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
         <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
 <script src="__STATIC__/layout/js/common.js"></script>
  <script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
  
   <script src="__STATIC__/layout/js/plugins/laydate/laydate.js"></script>
    <script>
$("input[name='zfjin']").blur(function(){
	 if(!isNaN(parseFloat($(this).val())))
                 var num=parseFloat($(this).val()).toFixed(2);
                else
                    var num="0.00";
                $(this).val(num);
})
    var weizhifu={$all.weifu};

    function yanzheng(){
    	var msg="";
    	if($("input[name='zfpz']").val()==""){
    		msg="支付凭证不能为空";
    	}else if($("input[name='c_users_id']").val()==""){
    		msg="支付人必须选择";
    	}else if($("input[name='zhifu_day']").val()==""){
    		msg="支付日期必须选择";
    	}else if($("input[name='zfjin']").val()==""){
    		msg="支付金额必须填写";
    	}else if(parseFloat($("input[name='zfjin']").val())>parseFloat(weizhifu)){
    		msg="支付金额不能超出未付金额";
    	}else if(parseFloat($("input[name='zfjin']").val())<=0){
    		msg="支付金额不能为0";
    	}
    	return msg;
    }
    $("#bc").click(function(){
    	var msg=yanzheng();
    	if(msg==""){
    			  $.ajax({
                        cache: true,
                        type: "POST",
                        url:"{:url('zhifuchuli')}",
                        data:$('#f1').serialize(),// 你的formid
                        async: false,
                        error: function(requests) {
                            alert("Connection error");
                        },
                        success: function(datas) {
                        // alert(datas);
                          
                        var res1=JSON.parse(datas);
                          if(res1["state"]==1){
                            swal({
                            title: "完成",
                            text: "操作已成功",
                            type: "success"
                            },function(){
                              
                              location.href="{:url('apCost_pay')}";
                            });

                                  }else{
                                    swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                                  }
                          }
                    });
    	}else{
    		 swal({
                    title: "错误",
                    text:  msg,
                    type: "warning"
                    });
    	}
    })
        //取消单选
    
    $('body').on('click','.selectedOnlyOne .close',function () {
        $(this).closest('.selectedOnlyOne').hide().find('.inin').html('')
        $(this).closest('.selectedOnlyOne').prev('.input-group').show().find('input').val('')
    })
     //弹出选择我的支付人树
        $('body').on('click','.select_cname',function () {
            var _this = this
                layer.open({
                    type:2,
                    area:['60%','60%'],
                    title:'支付人树',
                    maxmin:true,
                    content:'{:url("selectCname")}',
                    btn:'确定',
                    btnAlign:'c',
                    yes:function (i,o) {

                        var id = $(o).find('iframe').contents().find('#renyuan').val()
                        var name = $(o).find('iframe').contents().find('#renyuanname').val()
                        if(id){
                            $(_this).closest('div').prev('div').find('.input-group').hide().find('.feetype').val(id)
                            $(_this).closest('div').prev('div').find('.selectedOnlyOne').show().find('.inin').html(name)
                        }
                        layer.close(i)
                    }
                })
                return  false
        })
      	  //支付人搜索自动补全
    $(".cname").bsSuggest({
        url: "{:url('cnamejson')}",
        /*effectiveFields: ["userName", "shortAccount"],
         searchFields: [ "shortAccount"],*/
        effectiveFieldsAlias:{title: "名称"},
        ignorecase: true,
        showHeader: true,
        showBtn: false,     //不显示下拉按钮
        delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
        idField: "id",
        keyField: "title",
        clearable: true
    }).on('onSetSelectValue', function (e, keyword, data) {
        $(this).closest('.input-group').hide().next('.selectedOnlyOne').show().find('.inin').html(keyword.key)
        $(this).val(keyword.id)

    });
     function daochuhexiao(hid){
    location.href="{:url('Apapply/daochuhexiao')}?hid="+hid;
  }
    function back(){
    	location.href='{:url("apCost_pay")}';
    }
     $(".num2").each(function(){
                if(!isNaN(parseFloat($(this).html())))
                 var num=parseFloat($(this).html()).toFixed(2);
                else
                    var num="0.00";
                $(this).html(num);
            })
       
       laydate.render({
       		elem: '#start',
			format: 'yyyy-MM-dd'
       })
    </script>
</body>

</html>
